# -*- coding: utf-8 -*-
"""
author:码同学 极光
date:2024/9/28
desc: 
sample: 
"""
import re

r = r"\d+"
m = re.findall(r, "a123test123111")
print(m)

#数组d 字符 w
#万能匹配 .+(任意1个以上字符) .* (任意0+字母)
str = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' \
      ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">' \
      '<soap:Body><getMobileCodeInfoResponse xmlns="http://WebXml.com.cn/"><getMobileCodeInfoResult>18810703325：北京 北京 北京移动全球通卡' \
      '</getMobileCodeInfoResult></getMobileCodeInfoResponse></soap:Body></soap:Envelope>'

reg=r'<getMobileCodeInfoResult>.*</getMobileCodeInfoResult>'
m = re.findall(reg, str)
print(m)

#分组
reg2=r'<getMobileCodeInfoResult>(.*)</getMobileCodeInfoResult>'
m = re.findall(reg2, str)[0]
print(m.split('：'))
m_local=m.split('：')[1]
print(m_local)

str='a123ba456bab'  #贪婪 最大匹配
print(re.findall('a(.+)b', str)) #起码1个
print(re.findall('a(.+?)b', str)) #非贪婪 最小匹配
print(re.findall('a(.*)b', str))
print(re.findall('a(.*?)b', str)) # 0到多个


p = re.compile('a(.*?)b')
# m = p.search(str)
print(m)
# http://login?username=${name}
# 使用finditer()来找到所有非重叠匹配
matches = p.finditer(str)
for match in matches:
      print(match.group())
      print(match.group(1))
      print('------')
